<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace backend\assets;

use yii\web\AssetBundle;

/**
 * Main application asset bundle.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'static/layui/css/layui.css',
        'static/dist/style/admin.css',
    ];
    public $js = [
        'static/layui/layui.js',
        'static/dist/init.js',
        //'admin.js',
        //'js/view.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset',
    ];

    //定义按需加载JS方法，注意加载顺序在最后
    public static function addJs($view, $jsfile) {
        $view->registerJsFile(
            $jsfile,
            [
                AppAsset::class,
                "depends" => "backend\assets\AppAsset"
            ]
        );
    }
    //定义按需加载css方法，注意加载顺序在最后
    public static function addCss($view, $cssfile) {
        $view->registerCssFile(
            $cssfile,
            [
                AppAsset::class,
                "depends" => "backend\assets\AppAsset"
            ]
        );
    }
}
